package com.cy.validation;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class NotEqualsValidator implements
        ConstraintValidator <NotEquals,Integer>{

    //用來
    Integer aValue;

    //初始化方法，一般重鞋後來用來獲取對應註解中的屬性值
    @Override
    public void initialize(NotEquals constraintAnnotation) {
        this.aValue=constraintAnnotation.value();
    }

    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
       if(value != null){
        return !value.equals(aValue);
       }
       return true;
    }

}
